<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        管理员列表
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <script type="text/javascript" src="lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="css/main.css" media="all">
    <link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>管理员管理</cite></a>
              <a><cite>管理员列表</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <form class="layui-form x-center" action="" style="width:80%">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item">

                <div class="layui-input-inline">
                    <input type="text" id="st_ID"  placeholder="请输入管理员ID" class="layui-input">
                </div>
                <div class="layui-input-inline" style="width:80px">
                    <button type="button" class="layui-btn" id="btnfindByAD_ID" ><i class="layui-icon">&#xe615;</i></button>
                </div>
                <div class="layui-input-inline">
                    <label></label>
                </div>
                <div class="layui-input-inline">
                    <input type="text" id="ad_NAME" placeholder="请输入管理员用户名" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline" style="width:80px">
                    <button class="layui-btn" type="button" id="btnfindByAD_NAME" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                </div>
            </div>
        </div>
    </form>
    <xblock>
        <span class="x-right" style="line-height:40px">共有数据：<span class="layui-badge" ><label id="ad_n">2</label></span> 条</span>
    </xblock>
</div>



    <table class="layui-table">
        <thead>
        <tr>
            <th>
                #
            </th>
            <th>
                管理员编号
            </th>
            <th>
                用户名
            </th>
            <th>
                密码
            </th>
        </tr>
        </thead>
        <tbody id="ad_info">
        <tr>
            <td>
                1
            </td>
            <td>
                admin
            </td>
            <td>
                1111111111
            </td>
            <td>
                1111111@qq.com
            </td>


        </tr>


        </tbody>
    </table>

<div id="page"><ul class="pagination"><li class="disabled"><span>&laquo;</span></li> <li class="active"><span>1</span></li><li><a href="">&raquo;</a></li></ul></div>

<script src="lib/layui/layui.js" charset="utf-8"></script>
<script src="js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element();//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        okLoading.close($);
        //以上模块根据需要引入
        adminInfo()
        $("#btnfindByAD_ID").click(function (){
            var id = $("#st_ID").val()
            // alert(id)
            $.ajax({
                url: "/admin/findById?ad_ID="+id,
                async:true,
                dataType: "json",
                contentType:"application/json",
                success:function (res){
                    if(res.state === 200) {
                        var e = res.data
                        $("#ad_info").empty()
                        $("#ad_info").append("<tr>")
                            .append("<td>" + 1 +"</td>")
                            .append("<td>" + e.ad_ID + "</td>")
                            .append("<td>" + e.userName + "</td>")
                            .append("<td>" + e.password + "</td>")
                    }
                    $("#ad_n").text(1);
                }
            })
        })
        $("#btnfindByAD_NAME").click(function (){
            var name = $("#ad_NAME").val()
            // alert(name)
            $.ajax({
                url:"/admin/findByName?username="+name,
                dataType:"json",
                contentType: "application/json",
                success: function (res){
                    if(res.state === 200){
                        var e = res.data
                        $("#ad_info").empty()
                        $("#ad_info").append("<tr>")
                            .append("<td>"+ 1 +"</td>")
                            .append("<td>" + e.st_ID + "</td>")
                            .append("<td>" + e.userName + "</td>")
                            .append("<td>" + e.password + "</td>")
                        $("#st_n").text(1);
                    }
                }
            })
        })
    });
    function adminInfo() {
        $.ajax({
            url: "/admin/findAll",
            dataType: "json",
            async:true,
            success(res) {
                if (res.state === 200) {
                    var n = 0;
                    $("#ad_info").empty()
                    $.each(res.data, function (i, e) {
                        n++;
                        $("#ad_info").append("<tr>")
                            .append("<td>" + (i+1) +"</td>")
                            .append("<td>" + e.ad_ID + "</td>")
                            .append("<td>" + e.userName + "</td>")
                            .append("<td>" + e.password + "</td>")
                    })
                    $("#ad_n").text(n);
                }
            }
        })
    }


</script>

</body>
</html>